# 7

INF = 2147483647


class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        sign = 1
        if x < 0:
            sign = -1
            txt = str(x)[1:]
        else:
            txt = str(x)
        txt = txt[::-1]
        result = sign * int(txt)
        if result > INF or result < -INF:
            return 0
        return result


s = Solution()
print(s.reverse(-123))
